{% extends 'common/base.html' %}

{% block content %}
    <div class="layui-container">
        <div class="layui-row layui-col-space15">
            {# 中心区内容 #}
            <div class="layui-col-md9">
                <div style="height:800px; width: 100%;">
                    {% for post in post_pg %}
                        <div class="post-card">
                            <h2><a style="color: #227eaa;"
                                   href="{{ url_for('blog.post', post_id=post.id) }}">{{ post.title }}</a></h2>
                            <div class="clamp-text">{{ post.content_html | remove_html_tags }}</div>
                            <div class="post-msg">
                            <span>
                                <i class="layui-icon">&#xe612;</i>
                                <span class="author">山禾</span>
                            </span>
                                <span>
                                <i class="layui-icon">&#xe705;</i>
                                <a href="#" class="category">{{ post.category.name }}</a>
                            </span>
                                <span>
                                <i class="layui-icon">&#xe68d;</i>
                                <span class="post-info">{{ post.add_time | strftime_comment }}</span>
                            </span>
                                <span>
                                <i class="layui-icon">&#xe62c;</i>
                                <span class="post-info">{{ post.read_count }}</span>
                            </span>
                                <span>
                                <a href="{{ url_for('blog.post', post_id=post.id) }}" class="detail">阅读全文</a>
                            </span>
                            </div>
                        </div>
                    {% endfor %}
                    <div id="demo-laypage-theme-1"></div>
                </div>

            </div>
            {# 右边侧边栏 #}
            <div class="layui-col-md3">
                <div style="height:800px; width: 100%;">
                    {% include 'common/module/search.html' %}
                    {% include 'common/module/my_info.html' %}
                    {% include 'common/module/categorys.html' %}
                    {% include 'common/module/recent_posts.html' %}
                    {% include 'common/module/tags.html' %}
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block script %}
    <script>
        layui.use(function () {
            let laypage = layui.laypage;
            laypage.render({
                elem: 'demo-laypage-theme-1',
                curr: '{{ curr }}',
                count: '{{ count }}',
                theme: '#1E9FFF',
                limit: 5,
                jump: (obj, first) => {
                    // 首次不执行
                    if (!first) {
                        window.location.href = `/blog/page/${obj.curr}`
                        console.log(obj.curr)
                        console.log(obj.limit)
                    }
                }
            });
        });
    </script>
{% endblock %}
